<?php
namespace EasySwoole\EasySwoole;


use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use EasySwoole\HotReload\HotReload;
use EasySwoole\HotReload\HotReloadOptions;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\EasySwoole\AbstractInterface\Event;

class EasySwooleEvent implements Event
{

    public static function initialize()
    {
        // TODO: Implement initialize() method.
        date_default_timezone_set('Asia/Shanghai');
    }

    public static function mainServerCreate(EventRegister $register)
    {
          // 配置同上别忘了添加要检视的目录
          $hotReloadOptions = new \EasySwoole\HotReload\HotReloadOptions;
          $hotReload = new \EasySwoole\HotReload\HotReload($hotReloadOptions);
          $hotReloadOptions->setMonitorFolder([EASYSWOOLE_ROOT . '/App']);
  
          $server = ServerManager::getInstance()->getSwooleServer();
          $hotReload->attachToServer($server);
        // TODO: Implement mainServerCreate() method.
    }

    public static function onRequest(Request $request, Response $response): bool
    {
        // TODO: Implement onRequest() method.
        return true;
    }

    public static function afterRequest(Request $request, Response $response): void
    {
        // TODO: Implement afterAction() method.
    }
}